<template>
  <view v-if="params.url">
    <web-view :webview-styles="webviewStyles" :src="`${pdfurl}`"></web-view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        params: {},
        pdfurl:'',
        webviewStyles: {
          progress: {
            color: "#FF3333"
          }
        }
      }
    },
    props: {
      src: {
        type: [String],
        default: null
      }
    },
    onLoad(event) {
      this.params = event
      this.pdfurl = "/static/pdf/render-viewer.html?file="+this.params.url
      if (event.title) {
        uni.setNavigationBarColor({
            frontColor: '#ffffff',
            backgroundColor: 'rgb(112, 153, 180)',
            animation: {
                duration: 400,
                timingFunc: 'easeIn'
            }
        })
        uni.setNavigationBarTitle({
          title: event.title
        })
      }
    }
  }
</script>
